package strutsNcrank.crud;

import java.util.HashMap;

import org.apache.commons.logging.Log;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.dispatcher.Dispatcher;
import org.apache.struts2.util.StrutsTestCaseHelper;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;

import com.opensymphony.xwork2.ActionContext;

public class BaseCrudTestCase extends AbstractTransactionalDataSourceSpringContextTests {
	protected transient final Log log = logger;

	@Override
	protected String[] getConfigLocations() {
        super.setAutowireMode(AUTOWIRE_BY_NAME);
        return new String[] {
                "classpath*:/applicationContext.xml"
            };
	}

	@Override
	protected void onSetUpBeforeTransaction() throws Exception {
//		Dispatcher dispatcher = StrutsTestCaseHelper.initDispatcher(null);
//		log.debug("Dispatcher: " + dispatcher);
//		log.debug("ActionContext.getContext() = " + ActionContext.getContext());
//		ActionContext.getContext().setSession(new HashMap());
//		ServletActionContext.setRequest(new MockHttpServletRequest());
		super.onSetUpBeforeTransaction();
	}

	@Override
	protected void onTearDownAfterTransaction() throws Exception {
//		ActionContext.getContext().setSession(null);
//		StrutsTestCaseHelper.tearDown();
		super.onTearDownAfterTransaction();
	}

}
